package com.leetcode.LC;

import java.util.ArrayList;

public class LC1313 {
    public int[] decompressRLElist(int[] nums) {

        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < nums.length - 1; i += 2) {
            for (int j = 0; j < nums[i]; j++) {
                list.add(nums[i + 1]);
            }
        }

        int[] ints = new int[list.size()];
        int a = -1;
        for (Integer integer : list) {
            a++;
            ints[a] = integer;
        }
        return ints;
    }

    public static void main(String[] args) {
        for (int i : new LC1313().decompressRLElist(new int[]{1, 2, 3, 4})) {
            System.out.print(i+",");
        }
    }
}
